package chapter19;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/24 22:34
 */
public class ThreadLocalBasic {
    static ThreadLocal<Integer> container = new ThreadLocal<>();

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new Child());
        container.set(100);
        thread.start();
        thread.join();
        System.out.println("Parent thread:" + container.get());
    }

    static class Child implements Runnable {
        @Override
        public void run() {
            System.out.println("child first get:" + container.get());
            container.set(200);
            System.out.println("child thread:" + container.get());
        }
    }
}
